package com.xinhe.web.controller;

import com.querydsl.core.QueryResults;
import com.xinhe.web.annotation.WebUsed;
import com.xinhe.web.common.Result;
import com.xinhe.web.entity.Shop;
import com.xinhe.web.response.ShopView;
import com.xinhe.web.service.ShopService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "自提点门店", tags = {"自提点门店"})
@RestController
@RequestMapping(value = {"/shop"}, produces = {"application/json;charset=UTF-8"})

public class ShopController {
    @Autowired
    private ShopService shopService;

    @WebUsed
    @ApiOperation(httpMethod = "GET", value = "分页查询门店")
    @RequestMapping({"/pageShop"})
    public QueryResults<ShopView> pageShop(String name, int pageNum, int pageSize) {
        return this.shopService.pageShop(name,pageNum,pageSize);
    }
    @WebUsed
    @ApiOperation(httpMethod = "POST", value = "保存门店")
    @RequestMapping({"/saveShop"})
    public Result saveShop(Long id,String name,String province,String city,String area,
                           String detail,String longitude, String latitude,String remark,
                           Long userId,String address) {
        return this.shopService.saveShop( id, name, province, city, area,
                 detail, longitude,  latitude, remark,
                 userId, address);
    }

    @WebUsed
    @ApiOperation(httpMethod = "GET", value = "删除门店")
    @ApiImplicitParam(name = "shopId", value = "标识", required = true)
    @RequestMapping({"/deleteShop"})
    public Result deleteShop(Long shopId) {
        return this.shopService.delete(shopId);
    }

    @WebUsed
    @ApiOperation(httpMethod = "GET", value = "门店详情")
    @ApiImplicitParam(name = "shopId", value = "标识", required = true)
    @RequestMapping({"/detailShop"})
    public Result<Shop> detailShop(Long shopId) {
        return this.shopService.findById(shopId);
    }
    /*
    @ApiOperation(httpMethod = "GET", value = "根据经纬度距离-分页查询门店")
    @RequestMapping({"/pageShopDistance"})
    public PageResult<ShopDistanceView> pageShopDistance(ShopDistanceQuery query) {
        return this.shopService.pageShopDistance(query);
    }
*/
}
